Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that --ip-range is a CIDR address #5483

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

robmry
Copy link
Contributor

@robmry robmry commented Sep 26, 2024

- What I did

Avoid this sort of confusion (from the community Slack) ...

I think I have found a bug in docker (Docker version 27.3.1, build ce12230)
My network at home is a /20 not because I actually need the numbers of devices but to be able to give a complete /24 range to a macvlan while at the same at the same time keeping my devices on their normal ip's ( were a /24 prior )
so my range on my network is from 192.168.80.1-192.168.95.254
And when I try to create the macvlan it says

$ docker network create -d macvlan --subnet 192.168.80.0/20 --gateway 192.168.80.1 --ip-range 192.168.83.1-192.168.83.254 -o parent=eno1 macvlan-test
no matching subnet for range 192.168.83.1-192.168.83.254

- How I did it

Check that --ip-range is a CIDR address, to produce a better error message.

The original error message was from the CLI, but it used subnetMatches(s,r) to check that the range was ok - that function tries to deal with r being a single address as well as a subnet, so it missed the problem. (Validation at the daemon end of the API is already ok.)

- How to verify it

Updated test, and ...

# docker network create -d macvlan --subnet 192.168.80.0/20 --gateway 192.168.80.1 --ip-range 192.168.83.1-192.168.83.254 -o parent=eno1 macvlan-test
invalid CIDR address: 192.168.83.1-192.168.83.254

- Description for the changelog

n/a

@robmry robmry added area/networking kind/bugfix PR's that fix bugs labels Sep 26, 2024
@robmry robmry added this to the 28.0.0 milestone Sep 26, 2024
@robmry robmry self-assigned this Sep 26, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.03%. Comparing base (daabb15) to head (8fca0a1).
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5483       +/-   ##
===========================================
+ Coverage   43.17%   60.03%   +16.86%     
===========================================
  Files           6      345      +339     
  Lines         227    23434    +23207     
===========================================
+ Hits           98    14068    +13970     
- Misses        123     8391     +8268     
- Partials        6      975      +969     

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit c767b9b into docker:master Sep 26, 2024
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants